//
//  AppDelegate.swift
//  WBSwift
//
//  Created by 贺瑞 on 2017/6/24.
//  Copyright © 2017年 herui. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    var rootVC : UIViewController {
        return (UserInfo.userInfo()?.isLogin ?? false) ? AppDelegate.welComeVC() : AppDelegate.rootSB()
    }

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        UITabBar.appearance().tintColor = UIColor.orange
        
        window = UIWindow()
        window?.frame = UIScreen.main.bounds
        window?.rootViewController = rootVC
        window?.makeKeyAndVisible()
        
        return true
    }
    
}



extension AppDelegate {
    
    static func rootVCSwitch2SB() {
        UIApplication.shared.keyWindow?.rootViewController = AppDelegate.rootSB()
    }
    static func rootVCSwitch2Welcome() {
        UIApplication.shared.keyWindow?.rootViewController = AppDelegate.welComeVC()
    }

    static func rootSB() -> UIViewController {
        return UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
    }
    
    static func welComeVC() -> UIViewController {
        return WelcomeViewController()
    }

}
